package com.oxy.interceptor;

import org.springframework.dao.DataAccessException;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.oxy.util.Oxy;
import com.oxy.util.SysErrManager;

public class SysErrInterceptor extends AbstractInterceptor {
	private static final long serialVersionUID = -5143679212701403681L;

	@Override
	public String intercept(ActionInvocation act) throws Exception {
		String ret = null;
		
		try {
			ret = act.invoke();
		}
		catch(DataAccessException e) {
			throw Oxy.getSysErrManager().makeSysError(SysErrManager.ERRORS.DATA_ACCESS_ERR, e.getMessage(), e);
		}
		catch(Exception e) {
			throw Oxy.getSysErrManager().makeSysError(SysErrManager.ERRORS.INTERNAL_ERR, e);
		}
		
		return ret;
	}

}
